package com.cyzy.server.dao;

import com.cyzy.pojo.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserDao {
    /**
     * 根据openid来查询用户
     * @param openid
     * @return
     */
    @Select("select * from user where openid = #{openid}")
    User getByOpenid(String openid);

    /**
     * 插入数据
     * @param user
     */
    void insert(User user);

    /**
     * 接收从前端传来的用户id用以查询数据库对象
     * @param userId
     * @return
     */
    @Select("select * from user where id = #{userid}")
    User getById(Integer userId);

    @Update("update user set name = #{name}, phone_number = #{phoneNumber} where id = #{id}")
    void setProfile(Integer id, String name, String phoneNumber);

    @Update("update user set avatar = #{path} where id = #{id}")
    void setAvatar(String path, Integer id);
}
